import { Injectable, PipeTransform, ArgumentMetadata, BadRequestException } from '@nestjs/common'

@Injectable()
export class StringToNumberPipe implements PipeTransform {
    transform(value: string, metadata: ArgumentMetadata) {
       
        const val = parseInt(value, 10);
        if (isNaN(val)) {
            throw new BadRequestException('输入的值不能转化为number')
        }
        return val;
    }
}